package com.hwadee.teachingprocessmanagementsystem.service.base.impl;


import com.hwadee.teachingprocessmanagementsystem.service.base.RedisService;
import com.hwadee.teachingprocessmanagementsystem.util.ColorLoggerUtils;
import com.hwadee.teachingprocessmanagementsystem.util.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


/**
 * @Description: Redis业务实现
 * @Author: Jukomu
 * @Package: com.hwadee.teachingprocessmanagementsystem.service.base.impl
 * @Project: MyPetStore-SSM
 * @name: RedisServiceImpl
 * @Date: 2024/4/16 10:57
 * @Filename: RedisServiceImpl
 */
@Service("redisService")
@Transactional(rollbackFor = Exception.class)
public class RedisServiceImpl implements RedisService {
    @Autowired
    private RedisTemplate redisTemplate;
    private RedisUtils redisUtils = new RedisUtils();
    private ColorLoggerUtils logger = ColorLoggerUtils.getLogger(RedisServiceImpl.class);

    @Override
    public Object getCacheValue(String key) {
        return redisUtils.getValue(redisTemplate, key);
    }

    @Override
    public boolean storeValue(String key, Object value) {
        return redisUtils.cacheValue(redisTemplate, key, value);
    }

    @Override
    public boolean storeValue(String key, Object value, long timeout) {
        return redisUtils.cacheValue(redisTemplate, key, value, timeout);
    }

    @Override
    public boolean removeValue(String key) {
        return redisUtils.removeValue(redisTemplate, key);
    }

    @Override
    public boolean removeValues(String prefixKey) {
        return redisUtils.removeKeys(redisTemplate, prefixKey);
    }

}
